package com.fujitsu.nanjing.tieba.dao;

import com.fujitsu.nanjing.tieba.ibator.CoreUser;
import com.fujitsu.nanjing.tieba.ibator.CoreUserCriteria;
import java.util.List;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class CoreUserDAOImpl extends SqlMapClientDaoSupport implements CoreUserDAO {

    public CoreUserDAOImpl() {
        super();
    }

    public int countByExample(CoreUserCriteria example) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("core_user.countByExample", example);
        return count;
    }

    public int deleteByExample(CoreUserCriteria example) {
        int rows = getSqlMapClientTemplate().delete("core_user.deleteByExample", example);
        return rows;
    }

    public int deleteByPrimaryKey(String userid) {
        CoreUser _key = new CoreUser();
        _key.setUserid(userid);
        int rows = getSqlMapClientTemplate().delete("core_user.deleteByPrimaryKey", _key);
        return rows;
    }

    public void insert(CoreUser record) {
        getSqlMapClientTemplate().insert("core_user.insert", record);
    }

    public void insertSelective(CoreUser record) {
        getSqlMapClientTemplate().insert("core_user.insertSelective", record);
    }

    @SuppressWarnings("unchecked")
    public List<CoreUser> selectByExample(CoreUserCriteria example) {
        List<CoreUser> list = getSqlMapClientTemplate().queryForList("core_user.selectByExample", example);
        return list;
    }

    public CoreUser selectByPrimaryKey(String userid) {
        CoreUser _key = new CoreUser();
        _key.setUserid(userid);
        CoreUser record = (CoreUser) getSqlMapClientTemplate().queryForObject("core_user.selectByPrimaryKey", _key);
        return record;
    }

    public int updateByExampleSelective(CoreUser record, CoreUserCriteria example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("core_user.updateByExampleSelective", parms);
        return rows;
    }

    public int updateByExample(CoreUser record, CoreUserCriteria example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("core_user.updateByExample", parms);
        return rows;
    }

    public int updateByPrimaryKeySelective(CoreUser record) {
        int rows = getSqlMapClientTemplate().update("core_user.updateByPrimaryKeySelective", record);
        return rows;
    }

    public int updateByPrimaryKey(CoreUser record) {
        int rows = getSqlMapClientTemplate().update("core_user.updateByPrimaryKey", record);
        return rows;
    }

    protected static class UpdateByExampleParms extends CoreUserCriteria {
        private Object record;

        public UpdateByExampleParms(Object record, CoreUserCriteria example) {
            super(example);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}